package com.we823.cms.controller.manage.sys;

import javax.servlet.http.HttpServletRequest;

import com.github.pagehelper.PageInfo;
import com.we823.cms.common.web.pageable.PageRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.we823.cms.common.WebConstants;
import com.we823.cms.controller.manage.AbstractManageController;
import com.we823.cms.model.sys.Config;
import com.we823.cms.repository.service.sys.ConfigService;

@Controller
@RequestMapping(WebConstants.MANAGE_URL+"/config")
public class ConfigManageController extends AbstractManageController<Config, Integer> {

	private String baseUrl = WebConstants.MANAGE_URL+"/config/";
	
	private ConfigService configService;
	
	@Autowired
	public ConfigManageController(ConfigService configService) {
		super(configService);
		super.baseUrl=baseUrl;
		this.configService=configService;
		this.entityName="config";
	}

	@Override
	public PageInfo<Config> getData(PageRequest pageRequest,
									HttpServletRequest request, Model model, boolean pageable) {
		PageInfo<Config> configPage;
		if (pageable) {
			configPage = configService.findAll(pageRequest);
		}else {
			configPage = new PageInfo<>(configService.findAll(getSort(request)));
		}
		return configPage;
	}

	@Override
	public void setIndetity() {
		setResourceIdentity("sys:config");
	}

}
